package com.ctshk.sapp.cms.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.cms.dto.UserFeedbackDTO;
import com.ctshk.rpc.cms.req.UserFeedbackAddReq;
import com.ctshk.rpc.cms.req.UserFeedbackQueryReq;
import com.ctshk.rpc.cms.service.IUserFeedbackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 用户反馈表 前端控制器
 * </p>
 *
 * @author LiZhiming
 * @since 2021-04-23
 */
@Api(value = "用户反馈", tags = "用户反馈")
@RestController
@RequestMapping("/user-feedback")
public class UserFeedbackController extends BaseController {

    @DubboReference
    private IUserFeedbackService userFeedbackService;

    @ApiOperation(value = "新增用户反馈", notes = "新增用户反馈")
    @OperationLogAnnotation(operModul = OperationLogModel.CMS, operType = OperationLogType.ADD)
    @PostMapping("/add")
    public Result add(@RequestBody @Valid UserFeedbackAddReq req) {
        return userFeedbackService.insert(req, getCurrentUser(getRequest()));
    }

    @ApiOperation(value = "查询用户反馈", notes = "查询用户反馈")
    @OperationLogAnnotation(operModul = OperationLogModel.CMS, operType = OperationLogType.QUERY)
    @GetMapping("/queryById/{userFeedbackId}")
    public Result<UserFeedbackDTO> queryById(@PathVariable("userFeedbackId") String userFeedbackId) {
        return userFeedbackService.queryById(userFeedbackId);
    }

    @ApiOperation(value = "用户反馈分页查询", notes = "用户反馈分页查询")
    @OperationLogAnnotation(operModul = OperationLogModel.CMS, operType = OperationLogType.QUERY)
    @PostMapping("/queryList")
    public Result<PageResponse<UserFeedbackDTO>> queryList(@RequestBody @Valid UserFeedbackQueryReq req) {
        return Result.success(userFeedbackService.queryList(req));
    }
}
